home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0643B.ZIP / DB3FIXPO.DOC < prev    next >
Text File  |  1986-04-25  |  11KB  |  265 lines

  1.  
  2.  
  3.  
  4.                           DB3FIXPO - Version 1.0
  5.  
  6.                                     by
  7.  
  8.                            P. L. Olympia, Ph.D.
  9.                      President, Darwin Systems, Inc.
  10.                       DARWIN BBS, 301-251-9206
  11.                                  11/14/84
  12.  
  13.  
  14.   WHAT DB3FIXPO DOES
  15.  
  16.        DB3FIXPO  is  a program that repairs or recovers a damaged  dBASE 
  17.        III data base in 15 seconds or less regardless of the size of the 
  18.        data base. It was designed to save you lots of wasted hours, gray 
  19.        hair  and money.  It was first used on a damaged file with 1  Meg 
  20.        worth  of data and did the job in 10 seconds.   Even  Ashton-Tate 
  21.        does not know that the recovery can be made this way,  or if they 
  22.        do, they are not telling you. It can also do less demanding fixes 
  23.        described later in this document.
  24.  
  25.        I  am  hereby placing the program and this documentation  in  the 
  26.        public domain. You are free to share the program and its doc file 
  27.        with others on the following conditions:
  28.  
  29.        1.   DB3FIXPO.EXE and DB3FIXPO.DOC are distributed together,  and 
  30.             their names are not changed;
  31.  
  32.        2.   No changes are made to either DB3FIXPO.EXE or DB3FIXPO.DOC;
  33.  
  34.        3.   The files may NOT be sold.  Give them away but don't ask any 
  35.             money for them.  I am giving them away to you so you do  the 
  36.             same.
  37.  
  38.  
  39.   DISCLAIMER
  40.  
  41.        I  will not be responsible for any damage this program may do  to 
  42.        your data.  Now, that's a little funny since the program works on 
  43.        DAMAGED  data but I am obligated to say it nonetheless (I am  not 
  44.        crazy  about  this legal mumbo-jumbo either).   The  program  has 
  45.        always worked for me.   If it does not work for you,  chances are 
  46.        it is not the program's fault.
  47.  
  48.  
  49.   A LITTLE BACKGROUND
  50.  
  51.        I  have always told my staff to backup their dBASE III data bases 
  52.        at the end of each day. If you've ever done any serious work with 
  53.        dBASE II and III (which I like very much,  but are nonetheless as 
  54.        bug-ridden as the Mekong Delta) you know that it is good advice.
  55.  
  56.        Yesterday,  dBASE III reared its ugly head.  During a full screen 
  57.        edit operation on a data base with 1 Meg worth of data, the color 
  58.        screen  went flashing and the system became terminally  ill.  The 
  59.  
  60.  
  61.   DB3FIXPO  (c) 1984 Darwin Systems Inc.                           Page 1
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.        data base was thoroughly damaged (dBASE III can't even  recognize 
  71.        its  own data base).  The last backup was done 4 days before  and 
  72.        was seriously out-of-date.  The staff member is still with us but 
  73.        only because she  has other attributes (ahem!) which we won't  go
  74.        into here.
  75.  
  76.        Because  a complete report off the data base was needed the  next 
  77.        morning,  I  stayed up the whole night to recover the data  base. 
  78.        Here is what I did that night to recover the data:
  79.  
  80.        1.   Since the file was too large to repair via DEBUG,  I wrote a 
  81.             program  to  find  the beginning of the  data  records  (the 
  82.             header record damage extended into the data area). Now, this 
  83.             took a lot of tweaking because the header record did not end 
  84.             where it was supposed to end).
  85.  
  86.        2.   Having  found  the beginning of the data  area,  I  wrote  a 
  87.             little  program  to dump the data records into a text  file, 
  88.             and  add  a CR/LF sequence at the end of  each  record.  The 
  89.             program took 2.5 hours to complete its job.  That is not the 
  90.             program's  fault - there were just too much data.   In fact, 
  91.             there  were so much data that at the end of the run,  I  had 
  92.             very little space left on my hard disk.
  93.  
  94.        3.   Next,  I  took  a file containing the same structure as  the 
  95.             damaged data base and ZAP(ped) its data records. (If you are 
  96.             unlucky enough not to keep a file with the same structure as 
  97.             the  damaged  file,  all  you have to do  is  re-create  the 
  98.             structure  via  the  dBASE  III  CREATE  command).   Then  I 
  99.             APPEND(ed)  the dumped text file generated in  step  2.  and 
  100.             Voila!, the damaged data base was completely restored!!
  101.  
  102.        Although the procedure worked,  it took nearly eight hours,  used 
  103.        up  disk space like it was going out of style,  and took a lot of 
  104.        painful tweaking and some manual intervention.  There had to be a 
  105.        better  way,  so  tonight I stayed up the whole night  again  and 
  106.        wrote DB3FIXPO that did the same thing in 10 seconds, and did not 
  107.        use a single byte of additional data disk space.
  108.  
  109.  
  110.   HOW TO USE THE PROGRAM
  111.  
  112.        Before you use the program, you need to have two DBF files:
  113.  
  114.        1.   The damaged DBF file (of course), and
  115.  
  116.        2.   A  DBF file containing the correct structure of the  damaged 
  117.             data  base.  You  either generate this with  the  dBASE  III 
  118.             command  COPY STRU TO or simply by recreating the  structure 
  119.             with  the  CREATE command.  It is NOT necessary to have  any 
  120.             data records on this second DBF.  The program simply uses it 
  121.             to reconstruct the damaged data base's header record.
  122.  
  123.        You also need to know approximately how many data records were in 
  124.        the damaged data base. If you don't know this number take a guess 
  125.  
  126.  
  127.   DB3FIXPO  (c) 1984 Darwin Systems Inc.                           Page 2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.        and  pick a number LARGER than what you think the correct  number 
  137.        is.  You can always DELETE the garbage records at the end of  the 
  138.        recovered data base.
  139.  
  140.        If your data base damage did not extend into the data area,  then 
  141.        all  you  have  to do is run the program and answer  "N"  to  the 
  142.        prompt,
  143.  
  144.             "Do you want to change the length of header record (Y/N)?"
  145.  
  146.        The  program assists you in determining the extent of the  damage 
  147.        by  dumping  the contents of the damaged file beginning with  the 
  148.        expected  beginning  of the data record area.  If the  data  base 
  149.        damage  did not extend into the data area,  the first  or  second 
  150.        byte  displayed should be the first CHARACTER of the first  FIELD 
  151.        in the data base.   If this is the case,  your data base is fully 
  152.        recovered and you can now invoke dBASE III and USE your recovered 
  153.        data  base.   If this is not the case,  put on your thinking cap, 
  154.        and read the APPENDIX below.
  155.  
  156.        DB3FIXPO  is as self-documenting as I can make it.  Invoke it  at 
  157.        the  DOS prompt and just follow the instructions and  respond  to 
  158.        the prompts.
  159.  
  160.   ADDITIONAL USES AND NOTES
  161.  
  162.        DB3FIXPO can also be used for some relatively simple fixes:
  163.  
  164.        1.   Suppose  you have a dBASE III DBF file with a MEMO field  (I 
  165.             don't  much  care  for MEMO fields at its present  state  of 
  166.             development).    Now,   suppose   you   somehow   lost   the 
  167.             corresponding DBT file.  Tough, dBASE III won't let you open 
  168.             the data base so you can at least recover all the other data 
  169.             except  for the MEMO field data.   DB3FIXPO can  patch  your 
  170.             data base so that dBASE III will think that there is no MEMO 
  171.             field or DBT file associated  with the data base.
  172.  
  173.        2.   The  program,  obviously,  can  also be used to correct  the 
  174.             data record count should that ever become corrupted.
  175.  
  176.   DID YOU KNOW?
  177.  
  178.        1.   That the dBASE III  command
  179.  
  180.                  APPE FROM <external-file> DELI 
  181.  
  182.             does not work correctly.   Now,  you know why the  DELIMITED 
  183.             option  is  not in the manual.   One approach is to  do  the 
  184.             APPEND  FROM <filename> DELIMITED of a comma-delimited  file 
  185.             into dBASE II and use dCONVERT to turn that into dBASE III.
  186.  
  187.        2.   That  (speaking  of ...) dCONVERT is unable to turn a  dBASE 
  188.             III DBF file into a dBASE II file.   That menu option number 
  189.             7,  for  d(un)CONVERT is a cruel joke perpetrated on  people 
  190.             who don't know any better. I'll write that utility later.
  191.  
  192.  
  193.   DB3FIXPO  (c) 1984 Darwin Systems Inc.                           Page 3
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.                APPENDIX - ABOUT THE LENGTH OF HEADER RECORD
  204.    
  205.        If  the damage extended to the data area,  pay attention  to  the 
  206.        byte dump that the program shows on your screen.  You are looking 
  207.        for  the  BYTE number that corresponds to the first CHARACTER  of 
  208.        the first FIELD of your data base.   This does NOT have to be the 
  209.        character belonging to the first data base record (if the  damage 
  210.        extended  to the first data base record,  this record may be lost 
  211.        and you are looking for the first character of the first field on 
  212.        the second data base record).  This sounds complicated but hey, I 
  213.        had to figure this out from scratch!
  214.  
  215.        Let us look at an example.
  216.  
  217.        Suppose you have a data base whose structure begins with:
  218.             NAME,C,30
  219.             COMPANY,C,40
  220.             CITY,C,25
  221.             ... other fields ...
  222.  
  223.        Now suppose the first 2 records in the data base begin like so:
  224.  
  225.             Jane Good                 Miles J. Away
  226.             ABC Corp                  XYZ, Inc
  227.             Rockville                 Zamboanga
  228.  
  229.        If  the  damage  is extensive or the length of header  record  is 
  230.        wrong, your "recovered" data base may look like this:
  231.  
  232.             NAME:                   :
  233.             COMPANY:             Rock:
  234.             CITY:ville         Mi:
  235.  
  236.        The  business of adjusting the length of header record is to have 
  237.        the recovered data line up correctly. The first character of NAME 
  238.        (the  first  field in the data base) should be either  "J"  (from 
  239.        "Jane  Good" of the first record) or "M" (from Miles J.  Away  of 
  240.        the second record).
  241.  
  242.        Suppose the byte dump of DB3FIXPO later shows you this:
  243.  
  244.            BYTE      CHAR
  245.             451       
  246.             452
  247.             453       J         <-- note this byte # (453) and subtract
  248.             454       a              1 from it.  Re-run the program  and 
  249.             455       n              use the result (452) as the length
  250.                                      of header record.
  251.  
  252.   CONCLUSION
  253.  
  254.        Implicit  in  all the foregoing is the fact that when  your  data 
  255.   base is damaged,  your data records are intact. Don't delete the file. 
  256.   Do a backup on the damaged file and run DB3FIXPO on it. ENJOY!!!
  257.  
  258.  
  259.   DB3FIXPO  (c) 1984 Darwin Systems Inc.                           Page 4
  260.  
  261.  
  262.  
  263.  
  264.  
  265.